package com.igeek.service;

import com.igeek.dao.IUserDao;
import com.igeek.dao.UserDaoImpl;
import javafx.application.Application;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author jerry
 * @Company 极客营
 */
public class UserServiceImpl implements IUserService {
    @Override
    public void login() {
        System.out.println("UserServiceImpl-service层被调用了。。。");
        //传统方式
//        IUserDao iUserDao = new UserDaoImpl();
//        iUserDao.findByUsernameAndPassword();
        //让spring帮我创建对象
        //1.加载配置文件
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        //2.找到要创建对象的id
        IUserDao userDao = (IUserDao) ac.getBean("userDao");
        //3.调用方法
        userDao.findByUsernameAndPassword();
    }
}
